package method;

public class Simple {
    //修饰符 public static
    //返回值类型 int
    //方法名 add
    //参数类型 int int，形式参数-用于定义
    public static int add(int a,int b) {
        return a+b;
    }

    public static int max(int a,int b) {
        if (a>b) {
            //返回值
            return a;
        } else if (b>a){
            return b;
        }
        //终止方法
        return 0;
    }

    //方法重载
    public static double max(double a,double b) {
        if (a>b) {
            return a;
        } else if (b>a){
            return b;
        }
        return 0;
    }

    //可变长参数传递
    public void lengthChange(int... i) {

    }

    public static void printMax(double... numbers) {
        if (numbers.length == 0) {
            System.out.println("No thing!");
            return;
        }
        double result = numbers[0];
        for (int i = 1; i < numbers.length; i++) {
            if (numbers[i] > result) {
                result = numbers[i];
            }
        }
        System.out.println("Max value:"+result);
    }

    public static double factorial(double n) {
        if (n==1) {
            return n;
        } else {
            return n*factorial(n-1);
        }
    }

    public static void main(String[] args) {
        //实际参数 3 6，实际参数-用于传值
        int num = add(3,6);
        int result = max(1,1);
        System.out.println(result);
        printMax(123,123,34,34123,345536.12,123);
        System.out.println(factorial(100));
    }
}
